<?php
$di = \Phalcon\Di::getDefault();
$output = array(
    '_id' => 'adminFileSettingsForm',
    '_form' => array(
        'method' => 'post',
        'ajax-submit' => '#main',
        'accept-charset' => 'utf-8',
        'role' => 'form',
        'id' => 'adminFileSettingsForm',
    ),
    'rename' => array(
        'label' => '文件重名',
        'userOptions' => array(),
        'description' => '是否重命名上传文件',
        'field' => 'boole',
        'widget' => 'Select',
        'value' => 1,
        'error' => '',
        'options' => array(
            1 => '开启',
            0 => '关闭',
        ),
        'validate' => array(),
        'filter' => ['boolval'],
        'attributes' => array(
            'class' => 'form-control',
        ),
    ),
    'roles' => array(
        'label' => '角色相关设置',
        'userOptions' => array(),
        'error' => '',
        'description' => '为角色设置相关上传、操作权限',
        'widget' => 'GroupTabs',
        'groupTabs' => array(),
        'validate' => array(),
        'attributes' => array(),
        'required' => false,
    ),
    '_options' => array(
        'save' => 'config',
        'storage' => 'm.file.config',
        'menuGroup' => array(),
        'module' => '内容',
        'title' => '设置',
        'description' => '内容相关设置',
    ),
);
if (!function_exists('getRolesOptions')) {
    unset($output['roles']);
    return $output;
}
$rolesOptions = array();
$rolesList = getRolesList();
foreach ($rolesList as $key => $roles) {
    $rolesOptions[$key] = $roles['name'];
    $output['roles']['groupTabs'][$key] = array(
        'Group' => 'Group',
        'label' => $roles['name'],
        'userOptions' => array(),
        'error' => '',
        'description' => $roles['name'] . '相关上传设置',
        'field' => 'group',
        'widget' => 'Group',
        'group' => array(
            $key . '_upload_access' => array(
                'label' => '上传权限',
                'userOptions' => array(),
                'error' => '',
                'description' => '允许上传文件权限',
                'widget' => 'Selects',
                'options' => array(
                    'private' => '上传私有文件',
                    'public' => '上传共有文件',
                ),
                'validate' => array(),
                'attributes' => array(
                    'class' => 'form-control',
                ),
                'required' => false,
            ),
            $key . '_upload_type' => array(
                'label' => '上传类型',
                'userOptions' => array(),
                'error' => '',
                'description' => '允许上传文件类型',
                'field' => 'list',
                'widget' => 'Selects',
                'options' => $di->getShared('config')->get('contentType'),
                'validate' => array(),
                'attributes' => array(
                    'class' => 'form-control',
                ),
                'required' => false,
            ),
            $key . '_upload_size_min' => array(
                'label' => '最小文件',
                'userOptions' => array(),
                'error' => '',
                'description' => '允许上传文件的大小限制，单位：kb',
                'widget' => 'Numeric',
                'validate' => array(),
                'attributes' => array(
                    'class' => 'form-control',
                ),
                'required' => true,
            ),
            $key . '_upload_size_max' => array(
                'label' => '最大文件',
                'userOptions' => array(),
                'error' => '',
                'description' => '允许上传文件的最大限制，单位：kb',
                'widget' => 'Numeric',
                'validate' => array(),
                'attributes' => array(
                    'class' => 'form-control',
                ),
                'required' => true,
            ),
            $key . '_private_img_down' => array(
                'label' => '私有文件下载',
                'error' => '',
                'description' => '允许上传文件的最大限制，单位：kb',
                'widget' => 'Selects',
                'validate' => array(),
                'options' => ['不允许', '允许'],
                'attributes' => array(
                    'class' => 'form-control',
                ),
                'filter' => ['boolval'],
                'required' => true,
            ),
        ),
        'validate' => array(),
        'attributes' => array(),
        'required' => false,
    );
}
return $output;